package com.example.basecore.factory;

import com.example.basecore.dto.Command;
import com.example.basecore.executor.CommandExecutor;

import java.util.Map;

/**
 * @author ycd0075
 * @date 2024-01-25 22:11
 */
public class CommandExecutorFactory {

    private Map<Class<? extends Command>, CommandExecutor> commandExecutorMap;

    public CommandExecutorFactory(Map<Class<? extends Command>, CommandExecutor> commandExecutorMap) {
        this.commandExecutorMap = commandExecutorMap;
    }

    public CommandExecutor create(Command command) {
        return commandExecutorMap.get(command.getClass());
    }
}
